package exer;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author tongchen
 * @create 2023-02-08 22:44
 */
public class MyExecutor {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 30, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(5),
                new ThreadPoolExecutor.AbortPolicy());
        //创建任务并提交至线程池，线程池就可执行任务
        for (int i=0;i<10;++i){
            int j=i;
            threadPoolExecutor.submit(()->{
                System.out.println(Thread.currentThread().getName()+"执行任务"+j);

            });
        }
    }
}
